import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
} from "vue-router";

// import Home from "../views/home/index.vue";

const router = createRouter({
  // 路由模式
  history: createWebHistory(), // 使用history模式
  // 路由配置项
  routes: [
    {
      path: "/", // 路径路径
      // component: Home, // 路由组件
      component: () => import("../views/home/index.vue"), // 路由懒加载
      name: "Home", // 命名路由
      children: [], // 子路由
      // meta参数
      meta: {
        title: "首页",
      },
    },
    {
      path: "/login",
      component: () => import("../views/login/index.vue"),
      name: "Login",
      meta: {
        title: "登录",
      },
    },
    {
      path: "/detail/:id",
      component: () => import("../views/detail/index.vue"),
      name: "Detail",
    },
    {
      path: "/:pathMatch(.*)*", // 匹配所有路径（不包含之前的路径）
      redirect: "/",
    },
  ],
});

export default router;
